<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px" @submit.native.prevent>
      <el-form-item label="用户名" prop="nickName">
        <el-input
          v-model="queryParams.nickName"
          placeholder="请输入用户名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="类型" prop="type">
        <dict-select :options="dict.type.order_type" v-model="queryParams.type" placeholder="请选择类型" />
      </el-form-item>
      <el-form-item label="收支类型" prop="status">
        <dict-select :options="dict.type.fund_change_type" v-model="queryParams.status" placeholder="请选择变动类型" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('search') }}</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('reset') }}</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="fundChangeList">
      <el-table-column label="用户名" align="center" prop="nickName" width="150"/>
      <el-table-column label="类型" align="center" prop="type" width="120">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.fund_change_type" :value="scope.row.type"></dict-tag>
        </template>
      </el-table-column>
      <el-table-column label="数量" align="center" prop="amountIncurred" width="150"/>
      <el-table-column label="变动前金额" align="center" prop="payBefore" width="150"/>
<!--      <el-table-column label="当前可用代币" align="center" prop="" width="150"/>-->
      <el-table-column label="备注" align="center" prop="description" width="500"/>
<!--      <el-table-column label="订单类型" align="center" prop="type" width="120">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.order_type" :value="scope.row.type.value"/>
        </template>
      </el-table-column>-->
<!--      <el-table-column label="变动说明" align="center" prop="remark" width="300"/>-->

      <el-table-column label="发生时间" align="center" prop="payDate" width="160"  :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span>{{ scope.row.payDate }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import {listFundChange} from "@/api/user/fund-change";
import DictSelect from "@/components/DictSelect/index.vue";
import Template from '@/views/setting/template/index.vue'

export default {
  name: "FundChange",
  components: { Template, DictSelect},
  dicts: ['fund_change_type', 'order_type','balance_inOut'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      // 总条数
      total: 0,
      // 资金变动记录表格数据
      fundChangeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        userId: [
          {required: true, message: "用户Id不能为空", trigger: "blur"}
        ],
        createTime: [
          {required: true, message: "创建时间不能为空", trigger: "blur"}
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询资金变动记录列表 */
    getList() {
      this.loading = true;
      listFundChange(this.queryParams).then(response => {
        this.fundChangeList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
